#ifndef __BIT_STREAM_H__
#define __BIT_STREAM_H__

#include <stdint.h>

class BitStream{
public:
    BitStream(uint8_t* buf,int _size):start(buf),size(_size),p(buf)
    {}
    ~BitStream();

    int ReadU1();
    int ReadU(int n);
    int ReadUE();
    int ReadSE();
    bool isFull();
    int ReadToEnd();
private:
    uint8_t* start = nullptr; //buffer的起始位置
    int size = 0;            //buffer的长度
    uint8_t* p = nullptr;   //所在的字节
    int bits_left = 8;     //bit所在字节的第几位
};



#endif